<?php
namespace addons\advertising\controller;
use think\addons\Controller;
class Admin extends Controller
{
  public function index()
  {
    return $this->fetch("/admin");
  }

  public function upload()
  {
    $name = input('type');
    $file = request()->file('image');
    if($file){
      $info = $file->validate(['size'=>3*1024*1024,'ext'=>'png'])->move(ROOT_PATH . 'public'.DS .'uploads' . DS . 'ad',$name);
      if($info){
        return json(["code" => 200,"msg" => "保存成功","path" =>DS .'uploads' . DS . 'ad'.DS .$info->getSaveName()]);
      }else{
       return json(["code" => 204 ,"msg" =>$file->getError()]);
      }
    }    
  }
}